package com.tiza.xiaoyoubao.ui.fragment;

import android.os.Bundle;
import android.widget.TextView;

import com.orhanobut.hawk.Hawk;
import com.tianze.library.base.BaseFragment;
import com.tiza.xiaoyoubao.R;
import com.tiza.xiaoyoubao.app.Constants;
import com.tiza.xiaoyoubao.entity.AdvancesCompleteInfo;
import com.tiza.xiaoyoubao.entity.MpJDTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.MpTmTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.TaskOperateInfo;
import com.tiza.xiaoyoubao.entity.TaskOrderInfo;
import com.tiza.xiaoyoubao.entity.TaskRebatesInfo;
import com.tiza.xiaoyoubao.entity.TaskShipMentsInfo;

import butterknife.BindView;

/**
 * Created by mapple on 17/4/14.
 * 手机京东任务详情2
 */

public class MpJdTaskDetail2Fragment extends BaseFragment {

    @BindView(R.id.tv_shopName)
    TextView tv_shopName;
    @BindView(R.id.tv_shopDescribe)
    TextView tv_shopDescribe;
    @BindView(R.id.tv_keyWord)
    TextView tv_keyWord;
    @BindView(R.id.tv_cJPrice)
    TextView tv_cJPrice;
    @BindView(R.id.tv_num)
    TextView tv_num;
    @BindView(R.id.tv_taskType)
    TextView tv_taskType;
    @BindView(R.id.tv_buyNumber)
    TextView tv_buyNumber;
    @BindView(R.id.tv_receiving)
    TextView tv_receiving;
    @BindView(R.id.tv_location)
    TextView tv_location;
    @BindView(R.id.tv_city)
    TextView tv_city;
    @BindView(R.id.tv_priceInterval)
    TextView tv_priceInterval;
    @BindView(R.id.tv_orderMessage)
    TextView tv_orderMessage;
    @BindView(R.id.tv_additionalRequest)
    TextView tv_additionalRequest;
    private AdvancesCompleteInfo advancesCompleteInfo;
    private TaskOperateInfo taskOperateInfo;
    private TaskRebatesInfo taskRebatesInfo;
    private TaskShipMentsInfo taskShipMentsInfo;
    private MpJDTaskOrderInfo mpJDTaskOrderInfo;
    Bundle args;
    private String state;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        args = getArguments();
        state = args.getString("state");
    }


    @Override
    protected int getLayoutId() {
        return R.layout.fragment_mp_jd_task_detail2;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        switch (state) {
            case "AdvancesComplate":
                AdvancesComplate();
                break;
            case "operate":
                Operate();
                break;
            case "rebates":
                Rebates();
                break;
            case "shipments":
                Shipments();
                break;
            case "orderTask":
                OrderTask();
                break;
            default:
                break;
        }
    }


    /**
     * 已完成
     */
    public void AdvancesComplate() {
        advancesCompleteInfo = (AdvancesCompleteInfo) args.getSerializable("info");
        tv_shopName.setText(advancesCompleteInfo.getShopName());
        tv_shopDescribe.setText(advancesCompleteInfo.getTitle());
        tv_keyWord.setText(advancesCompleteInfo.getKeywords());
        tv_cJPrice.setText(advancesCompleteInfo.getPrice());
        tv_num.setText(advancesCompleteInfo.getNumber());
        tv_taskType.setText(advancesCompleteInfo.getTypeName());
        tv_buyNumber.setText(advancesCompleteInfo.getNumber());
        tv_receiving.setText(advancesCompleteInfo.getReceiving());
        tv_location.setText(advancesCompleteInfo.getLocation());
        tv_city.setText(advancesCompleteInfo.getCity());
        tv_priceInterval.setText(advancesCompleteInfo.getPrice());
        tv_orderMessage.setText(advancesCompleteInfo.getMessage());
        if (advancesCompleteInfo.getRemarks().equals(" ")) {
            tv_additionalRequest.setText("商家无其他要求");
        } else {
            tv_additionalRequest.setText(advancesCompleteInfo.getRemarks());
        }
    }
    /**
     * 待操作
     */
    public void Operate() {
        taskOperateInfo = (TaskOperateInfo) args.getSerializable("info");
        tv_shopName.setText(taskOperateInfo.getShopName());
        tv_shopDescribe.setText(taskOperateInfo.getTitle());
        tv_keyWord.setText(taskOperateInfo.getKeywords());
        tv_cJPrice.setText(taskOperateInfo.getPrice());
        tv_num.setText(taskOperateInfo.getNumber());
        tv_taskType.setText(taskOperateInfo.getTypeName());
        tv_buyNumber.setText(taskOperateInfo.getNumber());
        tv_receiving.setText(taskOperateInfo.getReceiving());
        tv_location.setText(taskOperateInfo.getLocation());
        tv_city.setText(taskOperateInfo.getCity());
        tv_priceInterval.setText(taskOperateInfo.getPrice());
        tv_orderMessage.setText(taskOperateInfo.getMessage());
        if (taskOperateInfo.getMessage().equals(" ")) {
            tv_additionalRequest.setText("商家无其他要求");
        } else {
            tv_additionalRequest.setText(taskOperateInfo.getRemarks());
        }
    }
    /**
     * 待操作(订单任务)
     */
    public void OrderTask() {
        mpJDTaskOrderInfo = (MpJDTaskOrderInfo) args.getSerializable("info");
        tv_shopName.setText(mpJDTaskOrderInfo.getShopName());
        tv_shopDescribe.setText(mpJDTaskOrderInfo.getTitle());
        tv_keyWord.setText(mpJDTaskOrderInfo.getKeywords());
        tv_cJPrice.setText(mpJDTaskOrderInfo.getPrice());
        tv_num.setText(mpJDTaskOrderInfo.getNumber());
        tv_taskType.setText(mpJDTaskOrderInfo.getTypeName());
        tv_buyNumber.setText(mpJDTaskOrderInfo.getNumber());
        tv_receiving.setText(mpJDTaskOrderInfo.getReceiving());
        tv_location.setText(mpJDTaskOrderInfo.getLocation());
        tv_city.setText(mpJDTaskOrderInfo.getCity());
        tv_priceInterval.setText(mpJDTaskOrderInfo.getPrice());
        tv_orderMessage.setText(mpJDTaskOrderInfo.getMessage());
        if (mpJDTaskOrderInfo.getMessage().equals(" ")) {
            tv_additionalRequest.setText("商家无其他要求");
        } else {
            tv_additionalRequest.setText(mpJDTaskOrderInfo.getRemarks());
        }
    }
    /**
     * 待返款
     */
    public void Rebates() {
        taskRebatesInfo = (TaskRebatesInfo) args.getSerializable("info");
        tv_shopName.setText(taskRebatesInfo.getShopName());
        tv_shopDescribe.setText(taskRebatesInfo.getTitle());
        tv_keyWord.setText(taskRebatesInfo.getKeywords());
        tv_cJPrice.setText(taskRebatesInfo.getPrice());
        tv_num.setText(taskRebatesInfo.getNumber());
        tv_taskType.setText(taskRebatesInfo.getTypeName());
        tv_buyNumber.setText(taskRebatesInfo.getNumber());
        tv_receiving.setText(taskRebatesInfo.getReceiving());
        tv_location.setText(taskRebatesInfo.getLocation());
        tv_city.setText(taskRebatesInfo.getCity());
        tv_priceInterval.setText(taskRebatesInfo.getPrice());
        tv_orderMessage.setText(taskRebatesInfo.getMessage());
        if (taskRebatesInfo.getRemarks().equals(" ")) {
            tv_additionalRequest.setText("商家无其他要求");
        } else {
            tv_additionalRequest.setText(taskRebatesInfo.getRemarks());
        }
    }
    /**
     * 发货中
     */
    public void Shipments() {
        taskShipMentsInfo = (TaskShipMentsInfo) args.getSerializable("info");
        tv_shopName.setText(taskShipMentsInfo.getShopName());
        tv_shopDescribe.setText(taskShipMentsInfo.getTitle());
        tv_keyWord.setText(taskShipMentsInfo.getKeywords());
        tv_cJPrice.setText(taskShipMentsInfo.getPrice());
        tv_num.setText(taskShipMentsInfo.getNumber());
        tv_taskType.setText(taskShipMentsInfo.getTypeName());
        tv_buyNumber.setText(taskShipMentsInfo.getNumber());
        tv_receiving.setText(taskShipMentsInfo.getReceiving());
        tv_location.setText(taskShipMentsInfo.getLocation());
        tv_city.setText(taskShipMentsInfo.getCity());
        tv_priceInterval.setText(taskShipMentsInfo.getPrice());
        tv_orderMessage.setText(taskShipMentsInfo.getMessage());
        if (taskShipMentsInfo.getRemarks().equals(" ")) {
            tv_additionalRequest.setText("商家无其他要求");
        } else {
            tv_additionalRequest.setText(taskShipMentsInfo.getRemarks());
        }
    }
}
